package com.google.code.p.restrpc;

import org.apache.commons.lang.StringUtils;

/**
 * @author dz
 */
public enum RpcProtocal {
    
    HTTP("http", "http://"),
    HTTPS("https", "https://"),
    LOOKUP("lookup", "lookup:"),
    LOOKUPS("lookup", "lookups:");
    
    private String value;
    
    private String prefix;
    
    private RpcProtocal(String value, String prefix) {
        this.value = value;
        this.prefix = prefix;
    }
    
    public String value() {
        return this.value;
    }
    
    public String prefix() {
        return this.prefix;
    }
    
    public boolean isSupported(String url) {
        if (StringUtils.isEmpty(url)) {
            return false;
        }
        
        return url.startsWith(prefix);
    }
    
    @Override
    public String toString() {
        return this.value;
    }
    
}
